/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*   File:      AddMyPushButton.cpp
*   Author:    刘洋兵
*   Function:  设计显示表中每行最后一列的按键样式
*   Time:      2025-09-09
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

#include "AddMyPushButton.h"

/**
* @brief 初始化构造函数
*/
AddMyPushButton::AddMyPushButton(){}

/**
 * @brief  设计按键样式
 * @param  m_button 按键对象指针
 * @param  icon_number 按键图标索引
 */
void AddMyPushButton::setButton(QPushButton *m_button,IconNumber icon_number)
{
    QIcon icon = addQicon(icon_number);
    m_button->setIcon(icon);
    m_button->setFixedSize(30,30);
    m_button->setIconSize(QSize(25,25));
    m_button->setStyleSheet("QPushButton{color:white;"
                          "background-color:#f8f8f8;"
                          "font-family:黑体;"
                          "border: 0px;"
                          "border-radius: 15px;"
                          "}"
                          "QPushButton:hover"
                          "{"
                          "   background-color: #aa9c99;"
                          "}"
                          "QPushButton:pressed {"
                          "   background-color: #666361;"
                          "}");
}

/**
* @brief  根据图标索引获取对应图标
* @param  icon_number 按键图标索引
* @return 返回指定图标
*/
QIcon AddMyPushButton::addQicon(IconNumber icon_number)
{
    //按键图标
    QIcon icon;
    if(icon_number == IconNumber::Icon_Delete)
    {
        icon = QIcon(":/Icon/image/clear.png");              //删除
    }
    else if(icon_number == IconNumber::Icon_Edit)
    {
        icon = QIcon(":/Icon/image/edit.png");               //编辑修改
    }
    else if(icon_number == IconNumber::Icon_Detail)
    {
        icon = QIcon(":/Icon/image/detailed_data.png");      //详细
    }
    else if(icon_number == IconNumber::Icon_Refresh)
    {
        icon = QIcon(":/Icon/image/refresh.png");            //刷新
    }
    else if(icon_number == IconNumber::Icon_Positioning)
    {
        icon = QIcon(":/Icon/image/positioning.png");        //重定位
    }
    else if(icon_number == IconNumber::Icon_Cancel)
    {
        icon = QIcon(":/Icon/image/cancel.png");             //任务注销
    }
    else if(icon_number == IconNumber::Icon_Pause)
    {
        icon = QIcon(":/Icon/image/pause.png");              //AGV暂停
    }
    else if(icon_number == IconNumber::Icon_Continue)
    {
        icon = QIcon(":/Icon/image/continue.png");           //AGV继续
    }

    else if(icon_number == IconNumber::Icon_Replace_Task)
    {
        icon = QIcon(":/Icon/image/replace_task.png");           //AGV继续
    }
    else if(icon_number == IconNumber::Icon_Replace)
    {
        icon = QIcon(":/Icon/image/replace.png");           //AGV继续
    }
    else if(icon_number == IconNumber::Icon_Manual)
    {
        icon = QIcon(":/Icon/image/manual.png");           //AGV继续
    }

    return icon;
}
